package oa.web.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import oa.entity.Employee;

public class SecurityInterceptor extends HandlerInterceptorAdapter {
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		Employee emp = (Employee) request.getSession().getAttribute("employee");
		if (emp==null) {
			response.sendRedirect(request.getContextPath()  + "/login");
			return false;
		} else {
			return true;
		}
	}

}
